#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:robot
@file: clone_setting.py 
@version:
@time: 2022/05/31 
"""
SETTING_TEMPLATE = {
    "isSerialMode": False,
    "sync_type": "initial_sync+cdc",
    "readBatchSize": 10000,
    "notificationWindow": 0,
    "notificationInterval": 300,
    "readCdcInterval": 500,
    "maxTransactionLength": 12,
    "description": "",
    "cdcFetchSize": 1,
    "distinctWriteType": "intellect",
    "drop_target": False,
    "run_custom_sql": False,
    "needToCreateIndex": True,
    "increment": False,
    "isSchedule": False,
    "cronExpression": "",
    "isOpenAutoDDL": False,
    "cdcConcurrency": False,
    "cdcShareFilterOnServer": False,
    "transformModelVersion": "v1",
    "emailWaring": {
        "edited": False,
        "started": False,
        "error": True,
        "paused": True
    },
    "readShareLogMode": "STREAMING",
    "stopOnError": True,
    "syncPoints": [
        {
            "connectionId": "",
            "type": "current",
            "time": "",
            "date": "",
            "name": "",
            "timezone": "+08:00"
        }
    ],
    "processorConcurrency": 1,
    "transformerConcurrency": 1,
    "lagTimeFalg": False,
    "userSetLagTime": 0,
    "noPrimaryKey": True,
    "oracleLogminer": "automatically",
    "useCustomSQLParser": False,
    "manuallyMinerConcurrency": 1,
    "initialSyncBreakpoint": False,
    "mongoDeleteCache": True
}

CLONE = {"mappingTemplate": "cluster-clone"}
SYNC = {"mappingTemplate": "custom"}
INITIAL = {'sync_type': 'initial_sync'}
CDC = {'sync_type': 'cdc'}
INITIAL_CDC = {}


class DataflowSetting:

    def __init__(self):
        self.setting = SETTING_TEMPLATE.copy()

    def clone_initial(self):
        self.setting.update({
            **INITIAL,
            **CLONE,
        })
        return self.setting

    def clone_cdc(self):
        self.setting.update({
            **CDC,
            **CLONE
        })
        return self.setting

    def clone_initial_cdc(self):
        self.setting.update({
            **INITIAL_CDC,
            **CLONE
        })
        return self.setting

    def sync_initial(self):
        self.setting.update({
            **INITIAL,
            **SYNC,
        })
        return self.setting

    def sync_cdc(self):
        self.setting.update({
            **CDC,
            **SYNC
        })
        return self.setting

    def sync_initial_cdc(self):
        self.setting.update({
            **INITIAL_CDC,
            **SYNC
        })
        return self.setting

    def custom(self, kwargs):
        self.setting.update(kwargs)
        return self.setting
